﻿using BHan.Context;
using BHan.Model.Entity.Pojo;
using BHan.Repository.Common;
using BHan.Repository.IRepository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static Microsoft.EntityFrameworkCore.DbLoggerCategory;

namespace BHan.Repository
{
    public class MenuRepository : GenericService<AppDataContext, MenuModel>, IMenuRepository
    {
        public MenuRepository(AppDataContext dbContext) : base(dbContext){}

        public List<MenuModel> GetMenuList(string searchText)
        {
            if (string.IsNullOrEmpty(searchText))
            {
                var list = _dbSet.Where(it => it.delFlag == false).ToList();
               
                return list;
            }
            else
            {
                var list = _dbSet.Where(it =>it.menuName.Contains(searchText) && it.delFlag == false).ToList();
                return list;
            }
             
        }

        public MenuModel GetMenuModelById(int id)
        {
            var menuModel =  _dbSet.Where(it=>it.menuId == id).FirstOrDefault();
            return menuModel;
        }

        public List<MenuModel> GetNormalMenuList()
        {
            var list = _dbSet.Where(it=>it.status.Equals("正常") && it.delFlag == false).ToList();
            return list;
        }




    }
}
